package org.example.asm.easydatastructure;

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

/**
 * 队列 测试03
 * 1 入队 2 出队(得校验队中是否有元素) 3 输出队首元素 4 输出队列长度
 */
public class QueueTest03 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        Queue<Integer> queue = new LinkedList<>();
        for(int i = 0; i < n; i++)
        {
            int chose = in.nextInt();
            switch (chose) {
                case 1:
                    queue.offer(in.nextInt());
                    break;
                case 2:
                    if (queue.isEmpty()) {
                        System.out.println("ERR_CANNOT_POP");
                    } else {
                        queue.poll();
                    }
                    break;
                case 3:
                    if (queue.isEmpty()) {
                        System.out.println("ERR_CANNOT_QUERY");
                    } else {
                        System.out.println(queue.peek());
                    }
                    break;
                case 4:
                    System.out.println(queue.size());

            }
        }
    }
}
